<template>
  <div class="transaction-page">
    <!-- 页面标题区域 -->
    <div class="page-header">
      <div class="title-section">
        <h1 class="page-title">成交案例</h1>
        <span class="page-subtitle">transaction case</span>
      </div>
      <el-button type="text" class="more-link">查看更多</el-button>
    </div>

    <!-- 成交案例卡片区域 -->
    <div class="case-grid">
      <div 
        v-for="(caseItem, index) in transactionCases" 
        :key="caseItem.id"
        class="case-card"
      >
        <!-- 图片区域 -->
        <div class="case-image-container">
          <div class="image-error-state">
            <el-icon class="error-icon"><Picture /></el-icon>
            <span class="error-text">加载失败</span>
          </div>
        </div>

        <!-- 案例信息 -->
        <div class="case-info">
          <h3 class="case-title">{{ caseItem.title }}</h3>
          <p class="update-time">{{ caseItem.updateTime }}更新</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { Picture } from '@element-plus/icons-vue'

// 成交案例数据
const transactionCases = ref([
  {
    id: 1,
    title: '【成交案例】2019年中联49米...',
    updateTime: '2023-02-21',
    image: '' // 图片加载失败
  },
  {
    id: 2,
    title: '【成交案例】2012年三一五十...',
    updateTime: '2023-02-17',
    image: ''
  },
  {
    id: 3,
    title: '【成交案例】2010年三一9018...',
    updateTime: '2023-02-15',
    image: ''
  },
  {
    id: 4,
    title: '【成交案例】2007年中联37...',
    updateTime: '2023-02-10',
    image: ''
  }
])

// 查看更多功能
const viewMore = () => {
  console.log('查看更多成交案例')
  // 实际项目中这里可以跳转到详情页或加载更多数据
}
</script>

<style scoped>
.transaction-page {
  width: 1235px;
  margin: 0 auto;
  padding: 20px;
  background: #fff;
}

/* 页面标题区域 */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding-bottom: 15px;
  border-bottom: 2px solid #ffd700;
}

.title-section {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.page-title {
  font-size: 24px;
  font-weight: bold;
  color: #333;
  margin: 0;
}

.page-subtitle {
  font-size: 12px;
  color: #999;
  text-transform: uppercase;
}

.more-link {
  color: #666;
  font-size: 14px;
  padding: 8px 16px;
}

.more-link:hover {
  color: #e6a23c;
  background: rgba(255, 215, 0, 0.1);
}

/* 案例卡片网格布局 */
.case-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

/* 单个案例卡片 */
.case-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: all 0.3s ease;
  cursor: pointer;
}

.case-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* 图片容器 */
.case-image-container {
  position: relative;
  width: 100%;
  height: 160px;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 加载失败状态 */
.image-error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #999;
}

.error-icon {
  font-size: 48px;
  margin-bottom: 8px;
  color: #ccc;
}

.error-text {
  font-size: 14px;
}

/* 案例信息 */
.case-info {
  padding: 15px;
}

.case-title {
  font-size: 14px;
  color: #333;
  margin: 0 0 8px 0;
  line-height: 1.4;
  font-weight: 500;
}

.update-time {
  font-size: 12px;
  color: #999;
  margin: 0;
  
}

/* 响应式设计 */
@media (max-width: 768px) {
  .transaction-page {
    padding: 15px;
  }
  
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }
  
  .case-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
  }
  
  .case-image-container {
    height: 120px;
  }
}

@media (max-width: 480px) {
  .case-grid {
    grid-template-columns: 1fr;
  }
  
  .page-title {
    font-size: 20px;
  }
}
</style>